<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // var str = 'abcoefoxyozzopp';
        // var j = 0;
        // var arr = [];
        // var boo = -1;
        // do {
        //     boo = str.indexOf('o', boo + 1);
        //     if (boo !== -1) {
        //         arr.push(boo);
        //         j++;
        //     }
        // } while (boo !== -1)
        // console.log(arr, j);
        var str = 'abcoefoxyozzopp';
        var obj = {};
        for (var i = 0; i < str.length; i++) {
            a = str.charAt(i);
            if (obj[a]) {
                obj[a]++;
            } else {
                obj[a] = 1;
            }
        }
        console.log(obj);
        var max = 0,
            b = '';
        for (var k in obj) {
            if (obj[k] > max) {
                max = obj[k];
                b = k;
            }
        }

        console.log(`这个字符串中出现次数最多的字符为${b},出现的次数为${max}`);
    </script>
</head>

<body>

</body>

</html>